package com.fr.web;

import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.report.TemplateWorkBook;
import com.fr.report.adhoc.ADHOCReport;
import com.fr.report.adhoc.CrossedADHOCReport;
import com.fr.report.adhoc.SimpleADHOCReport;

public class ADHOCReportlet extends Reportlet
{
  public TemplateWorkBook createReport(ReportletRequest paramReportletRequest)
    throws ReportletException
  {
    if (paramReportletRequest.getParameter("adhocconfig") == null)
      return null;
    String str = (String)paramReportletRequest.getParameter("adhocconfig");
    JSONObject localJSONObject = null;
    try
    {
      localJSONObject = new JSONObject(str);
    }
    catch (JSONException localJSONException)
    {
      localJSONException.printStackTrace();
    }
    Object localObject = null;
    try
    {
      if (localJSONObject.has("reporttype"))
        if (localJSONObject.getInt("reporttype") == SimpleADHOCReport.TYPE)
          localObject = new SimpleADHOCReport();
        else
          localObject = new CrossedADHOCReport();
      ((ADHOCReport)localObject).parseJSON(localJSONObject);
    }
    catch (Exception localException)
    {
    }
    return ((TemplateWorkBook)((ADHOCReport)localObject).createWorkBook());
  }
}